<template>
  <div class="product">
    <h3>标题：{{ title }}</h3>
    <p>价格: {{ price }}元一根</p>
    <p>描述:{{ desc }} <button @click="bargin">砍一刀</button></p>
  </div>
</template>

<script>
export default {
  name: 'MyProduct',
  //接收父组件传值
  props: ['price', 'title', 'desc', 'id'],
  methods: {
    bargin() {
      //通知父组件触发事件
      this.$emit('bargin', this.id)
    },
  },
}
</script>

<style scoped></style>
